<?php
// application/modules/default/controllers/ErrorController.php
/**
 * demo-zf application
 *
 * default\ErrorController
 *
 * @author Adam Pilacki <adam.pilacki@gmail.com>
 */
class ErrorController
    extends Lib_Default_ActionAbstract
{

    public function errorAction()
    {
        Zend_Layout::getMvcInstance()->disableLayout();

        $errors = $this->_getParam('error_handler');

        switch ($errors->type) {
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:

                // 404 error -- controller or action not found
                $this->getResponse()->setHttpResponseCode(404);
                $this->view->message = 'Page not found';
                break;
            default:
                // application error
                $this->getResponse()->setHttpResponseCode(500);
                $this->view->message = 'Application error';
                break;
        }

        /**
         * DO NOT REMOVE CODE BELOW
         * COMMENT OUT WHEN SOMETHING GOES WRONG IN TESTS
         * USE FOR CLI DISPLAY
         */
//        error_reporting(E_ALL | E_STRICT);
//        echo PHP_EOL;
//        echo 'DUMP ' . __METHOD__ . ' line ' . __LINE__;
//        echo PHP_EOL;
//        var_dump($errors->exception->getMessage());
//        echo PHP_EOL;
//        exit();

        $this->view->exception = $errors->exception;
        $this->view->request   = $errors->request;
    }
}